#pragma warning(disable:4996)
#pragma warning(disable:6031)

#include <stdio.h>
#include <stdlib.h>

typedef struct list
{
	int n;
	struct list* next;
}list;

list* buy(int n)
{
	list* newnode = (list*)malloc(sizeof(list));
	if (newnode == NULL)
	{
		exit(-1);
	}
	newnode->next = NULL;
	newnode->n = n;
	return newnode;
}

void push(list** pphead, int n)
{
	list* newnode = buy(n);
	if (*pphead == NULL)
	{
		*pphead = newnode;
	}
	else
	{
		list* ptr = *pphead;
		while (ptr->next != NULL)
		{
			ptr = ptr->next;
		}
		ptr->next = newnode;
	}
}

void print(list* phead)
{
	list* ptr = phead;
	while (ptr != NULL)
	{
		printf("%d ", ptr->n);
		ptr = ptr->next;
	}
}

//int main()
//{
//	int n = 0;
//	list* p = NULL;
//	scanf("%d", &n);
//	while (n--)
//	{
//		int num = 0;
//		scanf("%d", &num);
//		push(&p, num);
//	}
//	print(p);
//	return 0;
//}